home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_562 / intuisup / borders / source.lzh / borders_test.c next >
C/C++ Source or Header  |  1991-10-20  |  4KB  |  149 lines

  1.         /*************************************
  2.          *                                   *
  3.          *            Borders v2.0           *
  4.          *   by Torsten Jürgeleit in 05/91   *
  5.          *                                   *
  6.          *            Test program           *
  7.          *                                   *
  8.          *************************************/
  9.  
  10.     /* Includes */
  11.  
  12. #include <exec/types.h>
  13. #include <graphics/gfxbase.h>
  14. #include <intuition/intuitionbase.h>
  15. #include <intuition/intuition.h>
  16. #include <functions.h>
  17. #include "/render/render.h"
  18. #include "borders.h"
  19.  
  20.     /* Defines */
  21.  
  22. #define WINDOW_WIDTH        600
  23. #define WINDOW_HEIGHT        200
  24. #define WINDOW_TITLE        (UBYTE *)" Borders test "
  25.  
  26. #define RENDER_INFO_FLAGS    (USHORT)(RENDER_INFO_FLAG_INNER_WINDOW | RENDER_INFO_FLAG_BACK_FILL)
  27. #define OPEN_WINDOW_FLAGS    (USHORT)(OPEN_WINDOW_FLAG_CENTER_WINDOW | OPEN_WINDOW_FLAG_RENDER_PENS)
  28.  
  29.     /* Globals */
  30.  
  31. struct IntuitionBase  *IntuitionBase;
  32. struct GfxBase        *GfxBase;
  33.  
  34.     /* Statics */
  35.  
  36. STATIC struct NewWindow  test_new_window = { 0, 0, WINDOW_WIDTH,
  37.    WINDOW_HEIGHT, 0, 0, CLOSEWINDOW, WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH |
  38.    SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE, NULL, NULL,
  39.    WINDOW_TITLE, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN };
  40.  
  41.     /* Defines for test borders */
  42.  
  43. #define TEST_BORDER1_TYPE        BORDER_DATA_TYPE_BOX1_IN
  44. #define TEST_BORDER1_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER1_WIDTH) / 2)
  45. #define TEST_BORDER1_TOP_EDGE        20
  46. #define TEST_BORDER1_WIDTH        (WINDOW_WIDTH / 2)
  47. #define TEST_BORDER1_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER1_TOP_EDGE)
  48.  
  49. #define TEST_BORDER2_TYPE        BORDER_DATA_TYPE_BOX2_IN
  50. #define TEST_BORDER2_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER2_WIDTH) / 2)
  51. #define TEST_BORDER2_TOP_EDGE        40
  52. #define TEST_BORDER2_WIDTH        (WINDOW_WIDTH / 3)
  53. #define TEST_BORDER2_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER2_TOP_EDGE)
  54.  
  55. #define TEST_BORDER3_TYPE        BORDER_DATA_TYPE_BOX1_OUT
  56. #define TEST_BORDER3_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER3_WIDTH) / 2)
  57. #define TEST_BORDER3_TOP_EDGE        60
  58. #define TEST_BORDER3_WIDTH        (WINDOW_WIDTH / 4)
  59. #define TEST_BORDER3_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER3_TOP_EDGE)
  60.  
  61. #define TEST_BORDER4_TYPE        BORDER_DATA_TYPE_BOX2_OUT
  62. #define TEST_BORDER4_LEFT_EDGE        ((WINDOW_WIDTH - TEST_BORDER4_WIDTH) / 2)
  63. #define TEST_BORDER4_TOP_EDGE        80
  64. #define TEST_BORDER4_WIDTH        (WINDOW_WIDTH / 8)
  65. #define TEST_BORDER4_HEIGHT        (WINDOW_HEIGHT - 2 * TEST_BORDER4_TOP_EDGE)
  66.  
  67.     /* Statics for test borders */
  68.  
  69. STATIC struct BorderData  test_border_data[] = {
  70.    {
  71.     TEST_BORDER1_TYPE,        /* bd_Type */
  72.     TEST_BORDER1_LEFT_EDGE,        /* bd_LeftEdge */
  73.     TEST_BORDER1_TOP_EDGE,        /* bd_TopEdge */
  74.     TEST_BORDER1_WIDTH,        /* bd_Width */
  75.     TEST_BORDER1_HEIGHT        /* bd_Height */
  76.    }, {
  77.     TEST_BORDER2_TYPE,        /* bd_Type */
  78.     TEST_BORDER2_LEFT_EDGE,        /* bd_LeftEdge */
  79.     TEST_BORDER2_TOP_EDGE,        /* bd_TopEdge */
  80.     TEST_BORDER2_WIDTH,        /* bd_Width */
  81.     TEST_BORDER2_HEIGHT        /* bd_Height */
  82.    }, {
  83.     TEST_BORDER3_TYPE,        /* bd_Type */
  84.     TEST_BORDER3_LEFT_EDGE,        /* bd_LeftEdge */
  85.     TEST_BORDER3_TOP_EDGE,        /* bd_TopEdge */
  86.     TEST_BORDER3_WIDTH,        /* bd_Width */
  87.     TEST_BORDER3_HEIGHT        /* bd_Height */
  88.    }, {
  89.     TEST_BORDER4_TYPE,        /* bd_Type */
  90.     TEST_BORDER4_LEFT_EDGE,        /* bd_LeftEdge */
  91.     TEST_BORDER4_TOP_EDGE,        /* bd_TopEdge */
  92.     TEST_BORDER4_WIDTH,        /* bd_Width */
  93.     TEST_BORDER4_HEIGHT        /* bd_Height */
  94.    }, {
  95.     INTUISUP_DATA_END        /* mark end of border data array */
  96.    }
  97. };
  98.     /* Prototypes */
  99.  
  100. VOID test_action(struct RenderInfo  *ri, struct Window  *win);
  101.  
  102.     /* Pragmas */
  103.  
  104. #pragma regcall(test_action(a0,a1))
  105.  
  106.     /* Borders test */
  107.  
  108.    LONG
  109. main(VOID)
  110. {
  111.    struct RenderInfo  *ri;
  112.    struct Window      *win;
  113.  
  114.    if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
  115.       if (GfxBase = OpenLibrary("graphics.library", 0L)) {
  116.      if (ri = get_render_info(NULL, RENDER_INFO_FLAGS)) {
  117.         if (win = open_window(ri, &test_new_window, OPEN_WINDOW_FLAGS)) {
  118.            test_action(ri, win);
  119.            CloseWindow(win);
  120.         }
  121.         free_render_info(ri);
  122.      }
  123.      CloseLibrary(GfxBase);
  124.       }
  125.       CloseLibrary(IntuitionBase);
  126.    }
  127.    return(0L);
  128. }
  129.     /* Perform IDCMP action */
  130.  
  131.    VOID
  132. test_action(struct RenderInfo  *ri, struct Window  *win)
  133. {
  134.    struct MsgPort       *up = win->UserPort;
  135.    struct IntuiMessage  *msg;
  136.    BOOL keepon = TRUE;
  137.  
  138.    display_borders(ri, win, &test_border_data[0], -0, -0);
  139.    do {
  140.       WaitPort(up);
  141.       while (msg = (struct IntuiMessage *)GetMsg(up)) {
  142.      if (msg->Class == CLOSEWINDOW) {
  143.         keepon = FALSE;
  144.      }
  145.      ReplyMsg((struct Message *)msg);
  146.       }
  147.    } while (keepon == TRUE);
  148. }
  149.